<script setup lang="ts">
    const props = defineProps<{
        hexColor: string;
        pause?: boolean;
    }>();
</script>

<template>
    <div
        :class="{ spinner: true, run: !props.pause }"
        :style="{
            '--clr': props.hexColor,
            '--clr-alpha': props.hexColor + '1a',
        }">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </div>
</template>

<style lang="scss" scoped>
    .spinner {
        width: 70.4px;
        height: 70.4px;
        transform-style: preserve-3d;
        scale: 0.6;
        transform: rotate(12deg) rotateX(-30deg) rotateY(60deg);
        &.run {
            animation: spinner 1.6s infinite ease;
        }
    }
    .spinner > div {
        background-color: var(--clr-alpha);
        height: 100%;
        position: absolute;
        width: 100%;
        border: 3.5px solid var(--clr);
    }
    .spinner div:nth-of-type(1) {
        transform: translateZ(-35.2px) rotateY(180deg);
    }
    .spinner div:nth-of-type(2) {
        transform: rotateY(-270deg) translateX(50%);
        transform-origin: top right;
    }
    .spinner div:nth-of-type(3) {
        transform: rotateY(270deg) translateX(-50%);
        transform-origin: center left;
    }
    .spinner div:nth-of-type(4) {
        transform: rotateX(90deg) translateY(-50%);
        transform-origin: top center;
    }
    .spinner div:nth-of-type(5) {
        transform: rotateX(-90deg) translateY(50%);
        transform-origin: bottom center;
    }
    .spinner div:nth-of-type(6) {
        transform: translateZ(35.2px);
    }
    @keyframes spinner {
        0% {
            transform: rotate(45deg) rotateX(-25deg) rotateY(25deg);
        }
        50% {
            transform: rotate(45deg) rotateX(-385deg) rotateY(25deg);
        }
        100% {
            transform: rotate(45deg) rotateX(-385deg) rotateY(385deg);
        }
    }
</style>
